﻿Imports System.Data.SqlServerCe
Imports Framework.Data

Namespace Backup
    Public Class IssuedContracts
        Shared Sub New()
            Dim aSelectColumns As String() = {"Id/UniqueId", "IssuedToBuddyId", "StoragePath", "StorageSize", "Comment", "Revoked"}
            ObjectPersister.DefineObject(GetType(Entities.Backup.IssuedContract), "BackupIssuedContracts", aSelectColumns)
        End Sub
        Private Sub New()
        End Sub

        Public Shared Function GetAll() As Generic.List(Of Entities.Backup.IssuedContract)
            Return ObjectPersister.GetAll(Of Entities.Backup.IssuedContract)()
        End Function
        Public Shared Function GetAllByBuddyId(ByVal buddyId As Integer) As Generic.List(Of Entities.Backup.IssuedContract)
            Dim strClause As String = "IssuedToBuddyId=@BuddyId"
            Dim sqlPar1 As New SqlCeParameter("@BuddyId", buddyId)
            Return ObjectPersister.GetAll(Of Entities.Backup.IssuedContract)(strClause, sqlPar1)
        End Function


        Public Shared Sub Save(ByVal contract As Entities.Backup.IssuedContract)
            Dim clsCmd As New SaveCommand(Of String)("BackupIssuedContracts", "Id", contract.UniqueId)
            clsCmd.AddParam("StorageSize", contract.StorageSize, False)
            clsCmd.AddParam("StoragePath", contract.StoragePath, False)
            clsCmd.AddParam("Comment", contract.Comment, True)
            clsCmd.AddParam("Revoked", contract.Revoked, False)
            clsCmd.AddParam("IssuedToBuddyId", contract.IssuedToBuddyId, False)

            clsCmd.Save()
        End Sub

    End Class
End Namespace